using System.Globalization;
using System.Xml.Serialization;

namespace HengTong.Kingdee.Connected_Services.WSExportMaterialFacadeSrvProxyService
{
    /// <summary>
    /// 物料数据信息
    /// </summary>
    [XmlRoot("DataInfo")]
    public class MaterialDataInfo
    {
        [XmlElement("DataHead")]
        public MaterialDataHead DataHead { get; set; }

        [XmlArray("DataEntries")]
        [XmlArrayItem("entry")]
        public List<MaterialDataEntry> DataEntries { get; set; }
    }

    /// <summary>
    /// 物料数据头
    /// </summary>
    public class MaterialDataHead
    {
        /// <summary>
        /// 冻结组织单元
        /// </summary>
        [XmlElement("freezeOrgUnit")]
        public string FreezeOrgUnit { get; set; }

        /// <summary>
        /// 最后更新用户
        /// </summary>
        [XmlElement("lastUpdateUser")]
        public string LastUpdateUser { get; set; }

        /// <summary>
        /// 生效状态
        /// </summary>
        [XmlElement("effectedStatus")]
        public int EffectedStatus { get; set; }

        /// <summary>
        /// 物料分组
        /// </summary>
        [XmlElement("materialGroup")]
        public string MaterialGroup { get; set; }

        /// <summary>
        /// 是否外购件
        /// </summary>
        [XmlElement("isOutsourcedPart")]
        public int IsOutsourcedPart { get; set; }

        /// <summary>
        /// 高度
        /// </summary>
        [XmlElement("height")]
        public string Height { get; set; }

        /// <summary>
        /// 描述
        /// </summary>
        [XmlElement("description")]
        public string Description { get; set; }

        /// <summary>
        /// 价格精度
        /// </summary>
        [XmlElement("pricePrecision")]
        public int PricePrecision { get; set; }

        /// <summary>
        /// 条形码
        /// </summary>
        [XmlElement("barCode")]
        public string BarCode { get; set; }

        /// <summary>
        /// 是否发送
        /// </summary>
        [XmlElement("isSend")]
        public int IsSend { get; set; }

        /// <summary>
        /// 设备属性
        /// </summary>
        [XmlElement("equipProperty")]
        public int EquipProperty { get; set; }

        /// <summary>
        /// 名称拼音
        /// </summary>
        [XmlElement("namePinYin")]
        public string NamePinYin { get; set; }

        /// <summary>
        /// 简称
        /// </summary>
        [XmlElement("simpleName")]
        public string SimpleName { get; set; }

        /// <summary>
        /// 编号索引
        /// </summary>
        [XmlElement("number4idx")]
        public string Number4idx { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        [XmlElement("status")]
        public int Status { get; set; }

        /// <summary>
        /// 外文名
        /// </summary>
        [XmlElement("foreignname")]
        public string Foreignname { get; set; }

        /// <summary>
        /// 发送消息
        /// </summary>
        [XmlElement("sendMsg")]
        public string SendMsg { get; set; }

        /// <summary>
        /// 宽度
        /// </summary>
        [XmlElement("width")]
        public string Width { get; set; }

        /// <summary>
        /// 编号
        /// </summary>
        [XmlElement("number")]
        public string Number { get; set; }

        /// <summary>
        /// 毛重
        /// </summary>
        [XmlElement("grossWeight")]
        public string GrossWeight { get; set; }

        /// <summary>
        /// 辅助单位
        /// </summary>
        [XmlElement("assistUnit")]
        public string AssistUnit { get; set; }

        /// <summary>
        /// 发送次数
        /// </summary>
        [XmlElement("sendCount")]
        public int SendCount { get; set; }

        /// <summary>
        /// 物料商标
        /// </summary>
        [XmlElement("materialTrademark")]
        public string MaterialTrademark { get; set; }

        /// <summary>
        /// 长度单位
        /// </summary>
        [XmlElement("lengthUnit")]
        public string LengthUnit { get; set; }

        /// <summary>
        /// 图片编号
        /// </summary>
        [XmlElement("pictureNumber")]
        public string PictureNumber { get; set; }

        /// <summary>
        /// 序列单位
        /// </summary>
        [XmlElement("seqUnit")]
        public string SeqUnit { get; set; }

        /// <summary>
        /// 是否称重
        /// </summary>
        [XmlElement("isWeighted")]
        public int IsWeighted { get; set; }

        /// <summary>
        /// 创建时间（原始字符串）
        /// </summary>
        [XmlElement("createTime")]
        public string CreateTimeString { get; set; }

        /// <summary>
        /// 创建时间（DateTime 类型）
        /// </summary>
        [XmlIgnore]
        public DateTime? CreateTime
        {
            get
            {
                if (string.IsNullOrWhiteSpace(CreateTimeString))
                    return null;
                if (DateTime.TryParseExact(CreateTimeString, "yyyy-MM-dd HH:mm:ss",
                    CultureInfo.InvariantCulture, DateTimeStyles.None, out var result))
                    return result;
                return null;
            }
        }

        /// <summary>
        /// 规格型号
        /// </summary>
        [XmlElement("model")]
        public string Model { get; set; }

        /// <summary>
        /// 注册商标
        /// </summary>
        [XmlElement("registeredmark")]
        public string Registeredmark { get; set; }

        /// <summary>
        /// 质保编号
        /// </summary>
        [XmlElement("warrantnumber")]
        public string Warrantnumber { get; set; }

        /// <summary>
        /// 名称索引
        /// </summary>
        [XmlElement("name4idx")]
        public string Name4idx { get; set; }

        /// <summary>
        /// 最后更新时间（原始字符串）
        /// </summary>
        [XmlElement("lastUpdateTime")]
        public string LastUpdateTimeString { get; set; }

        /// <summary>
        /// 最后更新时间（DateTime 类型）
        /// </summary>
        [XmlIgnore]
        public DateTime? LastUpdateTime
        {
            get
            {
                if (string.IsNullOrWhiteSpace(LastUpdateTimeString))
                    return null;
                if (DateTime.TryParseExact(LastUpdateTimeString, "yyyy-MM-dd HH:mm:ss",
                    CultureInfo.InvariantCulture, DateTimeStyles.None, out var result))
                    return result;
                return null;
            }
        }

        /// <summary>
        /// 是否商品
        /// </summary>
        [XmlElement("isGoods")]
        public int IsGoods { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        [XmlElement("creator")]
        public string Creator { get; set; }

        /// <summary>
        /// 版本
        /// </summary>
        [XmlElement("version")]
        public int Version { get; set; }

        /// <summary>
        /// 基本单位
        /// </summary>
        [XmlElement("baseUnit")]
        public string BaseUnit { get; set; }

        /// <summary>
        /// 使用辅助属性关系
        /// </summary>
        [XmlElement("useAsstAttrRelation")]
        public int UseAsstAttrRelation { get; set; }

        /// <summary>
        /// 是否同步
        /// </summary>
        [XmlElement("isSynochronous")]
        public int IsSynochronous { get; set; }

        /// <summary>
        /// 名称
        /// </summary>
        [XmlElement("name")]
        public string Name { get; set; }

        /// <summary>
        /// 长度
        /// </summary>
        [XmlElement("length")]
        public string Length { get; set; }

        /// <summary>
        /// 辅助属性
        /// </summary>
        [XmlElement("assistAttr")]
        public string AssistAttr { get; set; }

        /// <summary>
        /// 名称简拼
        /// </summary>
        [XmlElement("nameShortPinYin")]
        public string NameShortPinYin { get; set; }

        /// <summary>
        /// 是否自动审核
        /// </summary>
        [XmlElement("isAutoAudit")]
        public int IsAutoAudit { get; set; }

        /// <summary>
        /// CU
        /// </summary>
        [XmlElement("CU")]
        public int CU { get; set; }

        /// <summary>
        /// 重量单位
        /// </summary>
        [XmlElement("weightUnit")]
        public string WeightUnit { get; set; }

        /// <summary>
        /// 别名
        /// </summary>
        [XmlElement("alias")]
        public string Alias { get; set; }

        /// <summary>
        /// 体积单位
        /// </summary>
        [XmlElement("volumnUnit")]
        public string VolumnUnit { get; set; }

        /// <summary>
        /// 净重
        /// </summary>
        [XmlElement("netWeight")]
        public string NetWeight { get; set; }

        /// <summary>
        /// 旧编号
        /// </summary>
        [XmlElement("oldNumber")]
        public string OldNumber { get; set; }

        /// <summary>
        /// 管理CU
        /// </summary>
        [XmlElement("adminCU")]
        public int AdminCU { get; set; }

        /// <summary>
        /// 助记码
        /// </summary>
        [XmlElement("helpCode")]
        public string HelpCode { get; set; }

        /// <summary>
        /// 体积
        /// </summary>
        [XmlElement("volume")]
        public string Volume { get; set; }

        /// <summary>
        /// 短名称
        /// </summary>
        [XmlElement("shortName")]
        public string ShortName { get; set; }

        /// <summary>
        /// 长编号
        /// </summary>
        [XmlElement("longNumber")]
        public string LongNumber { get; set; }
    }

    /// <summary>
    /// 物料数据条目
    /// </summary>
    public class MaterialDataEntry
    {
        /// <summary>
        /// 物料分组标准
        /// </summary>
        [XmlElement("materialGroupStandard")]
        public string MaterialGroupStandard { get; set; }

        /// <summary>
        /// 物料分组
        /// </summary>
        [XmlElement("materialGroup")]
        public string MaterialGroup { get; set; }

        /// <summary>
        /// 物料
        /// </summary>
        [XmlElement("material")]
        public string Material { get; set; }
    }
}

